#ifndef WIDGET_H
#define WIDGET_H

#include <QScrollArea>
#include <QWidget>
#include <QLabel>
#include <QImage>
#include <QVector>
#include <QPoint>
#include <qsettings.h>
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

    void scaleImage();
    void drawLineTo(const QPoint &_lastPoint,const QPoint &_endPoint);
    QPoint realPoint(QPoint ps);
    void clearElem();
    double PolygonArea(QVector<QPoint> polygon);
private:
    Ui::Widget *ui;
    QLabel *imageLabel;
    QScrollArea *imagescroll;
    int processValue;
    float scrollFactor;
    QPoint lastPoint;
    bool ispress;
    bool ispaint;
    QSettings settings;
    QImage m_image;
    QVector<QPoint> arrPoint;
private slots:
    void openImage();
    void processbarvalue();
    void processPlus();
    void repaint();
    void autoclose();
    void calculateArea();
    void cancelPaint();
protected:
    void mousePressEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *event);
  //  void mouseMoveEvent(QMouseEvent *event);
};

#endif // WIDGET_H
